home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SERVICES.PAK / EXCEPT.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  103 lines

  1. //----------------------------------------------------------------------------
  2. // Borland Services Library
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.5  $
  6. //
  7. // Reliable include for standard C++ exception classes
  8. //----------------------------------------------------------------------------
  9. #if !defined(SERVICES_EXCEPT_H)
  10. #define SERVICES_EXCEPT_H
  11.  
  12. #if !defined(SERVICES_DEFS_H)
  13. # include <services/defs.h>
  14. #endif
  15.  
  16. //
  17. // Provide throw specifier macros that allow conditionally disabling the use
  18. // of throw specifiers based on the macro, BI_NO_THROWSPEC.
  19. // This can be turned on for compilers that don't support it, or for users
  20. // that dont want it.
  21. //
  22. #if defined(BI_NO_THROWSPEC)
  23. # define THROW_SPEC0
  24. # define THROW_SPEC1(x)
  25. # define THROW_SPEC2(x,x2)
  26. # define THROW_SPEC3(x,x2,x3)
  27. # define THROW_SPEC4(x,x2,x3,x4)
  28. #else
  29. # define THROW_SPEC0                    throw()
  30. # define THROW_SPEC1(x)                 throw(x)
  31. # define THROW_SPEC2(x,x2)              throw(x,x2)
  32. # define THROW_SPEC3(x,x2,x3)           throw(x,x2,x3)
  33. # define THROW_SPEC4(x,x2,x3,x4)        throw(x,x2,x3,x4)
  34. #endif
  35.  
  36. //
  37. // In a Borland C++ environment, use the file provided
  38. //
  39. #if defined(BI_COMP_BORLANDC)
  40. # include <except.h>
  41.  
  42. //
  43. // In a non-Borland C++ environment, use the C++ Exception Handling support
  44. // and add missing components of that support.
  45. //
  46. #else
  47. # if defined(BI_COMP_MSC)
  48. #   include <eh.h>
  49. # endif
  50.  
  51. # include <stdlib.h>
  52.  
  53. class _EXPCLASS string;
  54.  
  55. #if defined(BI_NAMESPACE)
  56. namespace ClassLib {
  57. #endif
  58.  
  59. class _EXPCLASS xmsg
  60. {
  61. public:
  62.     _RTLENTRY xmsg(const string _FAR &msg);
  63.     _RTLENTRY xmsg(const xmsg _FAR &msg);
  64.     _RTLENTRY ~xmsg();
  65.  
  66.     const string _FAR & _RTLENTRY why() const;
  67.     void                _RTLENTRY raise() THROW_SPEC1(xmsg);
  68.     xmsg&               _RTLENTRY operator=(const xmsg _FAR &src);
  69.  
  70. private:
  71.     string _FAR *str;
  72. };
  73.  
  74. inline const string _FAR & _RTLENTRY xmsg::why() const
  75. {
  76.     return *str;
  77. };
  78.  
  79. class _EXPCLASS xalloc : public xmsg
  80. {
  81. public:
  82.     _RTLENTRY xalloc(const string _FAR &msg, size_t size);
  83.  
  84.     size_t _RTLENTRY requested() const;
  85.     void   _RTLENTRY raise() THROW_SPEC1(xalloc);
  86.  
  87. private:
  88.     size_t siz;
  89. };
  90.  
  91. inline size_t _RTLENTRY xalloc::requested() const
  92. {
  93.     return siz;
  94. }
  95.  
  96. #if defined(BI_NAMESPACE)
  97. }       // namespace ClassLib
  98. #endif
  99.  
  100. #endif  // if/else BI_COMP_BORLANDC
  101.  
  102. #endif  // SERVICES_EXCEPT_H
  103.